/*
 * comboBoxWizard1.java
 *
 * Created on May 21, 2006, 12:27 AM
 */

import javax.swing.*;
import java.sql.*;
import com.mysql.jdbc.Driver;
import static java.lang.System.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
/**
 *
 * @author  yaco
 */
public class ComboBoxWizard1 extends javax.swing.JFrame {
   
   static public MyFrame mainFrame;
        
   static ComboBoxWizard1 comboBoxWizard1;
   static ComboBoxWizard2 comboBoxWizard2=new ComboBoxWizard2();
   static ComboBoxWizard3 comboBoxWizard3=new ComboBoxWizard3();
   static ComboBoxWizard4 comboBoxWizard4=new ComboBoxWizard4();
   static ComboBoxWizard5 comboBoxWizard5=new ComboBoxWizard5();
   static ComboBoxWizard6 comboBoxWizard6=new ComboBoxWizard6();
   static ComboBoxWizard7 comboBoxWizard7;
   static ComboBoxWizard8 comboBoxWizard8=new ComboBoxWizard8();
   
   boolean flag;
    /** Creates new form comboBoxWizard */
    public ComboBoxWizard1(MyFrame frame) {
        initComponents();
        this.mainFrame = frame;
        this.setSize(550,350);
        this.setLocation(250,200);
        buttonGroup1.add(jRadioButton1);
        buttonGroup1.add(jRadioButton2);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        buttonGroup1 = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jRadioButton1 = new javax.swing.JRadioButton();
        jRadioButton2 = new javax.swing.JRadioButton();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();

        getContentPane().setLayout(null);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Combo Box Wizard");
        setBackground(new java.awt.Color(204, 204, 204));
        setIconImage(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("mysql.JPEG"))
        );
        setResizable(false);
        getAccessibleContext().setAccessibleName("frame1");
        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/untitled.png")));
        jLabel1.setLabelFor(jLabel1);
        getContentPane().add(jLabel1);
        jLabel1.setBounds(10, 20, 120, 210);

        jRadioButton1.setSelected(true);
        jRadioButton1.setText("I want the list box to look up the values in a table.");
        jRadioButton1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        jRadioButton1.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jRadioButton1.setName("f1");
        getContentPane().add(jRadioButton1);
        jRadioButton1.setBounds(150, 130, 350, 15);

        jRadioButton2.setText("I will type in the values that i want.");
        jRadioButton2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        jRadioButton2.setMargin(new java.awt.Insets(0, 0, 0, 0));
        getContentPane().add(jRadioButton2);
        jRadioButton2.setBounds(150, 170, 250, 15);

        jButton1.setText("Cancel");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });

        getContentPane().add(jButton1);
        jButton1.setBounds(130, 280, 80, 23);

        jButton2.setText("<  Back");
        jButton2.setEnabled(false);
        getContentPane().add(jButton2);
        jButton2.setBounds(260, 280, 90, 23);

        jButton3.setText("Next  >");
        jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton3MouseClicked(evt);
            }
        });

        getContentPane().add(jButton3);
        jButton3.setBounds(350, 280, 90, 23);

        jButton4.setText("Finish");
        jButton4.setEnabled(false);
        getContentPane().add(jButton4);
        jButton4.setBounds(440, 280, 90, 23);

        getContentPane().add(jSeparator1);
        jSeparator1.setBounds(0, 0, 0, 2);

        getContentPane().add(jSeparator2);
        jSeparator2.setBounds(10, 260, 520, 20);

        jLabel2.setText("This wizard creates a combo box,which displays a list of values");
        getContentPane().add(jLabel2);
        jLabel2.setBounds(150, 30, 360, 14);

        jLabel3.setText("you can choose from.How do you want your combo box to get ");
        getContentPane().add(jLabel3);
        jLabel3.setBounds(150, 50, 360, 14);

        jLabel4.setText("its values?");
        getContentPane().add(jLabel4);
        jLabel4.setBounds(150, 70, 360, 14);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
    this.dispose();
// TODO add your handling code here:
    }//GEN-LAST:event_jButton1MouseClicked

    private void jButton3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton3MouseClicked
        if (jRadioButton2.isSelected()){
            flag=false;
            this.setVisible(false);
            ComboBoxWizard1.comboBoxWizard2=new ComboBoxWizard2();
            comboBoxWizard2.setVisible(true);
        }
        else{          
            flag=true;
            if(MainWindow.dbCon.getTables().isEmpty()){
               JOptionPane.showMessageDialog(null,"There are no tables that the Combo box wizard can get values from.You must enter your own data to continue in the wizard.","Combo Box Wizard", JOptionPane.INFORMATION_MESSAGE);
            }
            else{
                this.setVisible(false);
                ComboBoxWizard1.comboBoxWizard3=new ComboBoxWizard3();
                comboBoxWizard3.setVisible(true);
                ComboBoxWizard1.comboBoxWizard3.jList1.setSelectedIndex(0);
            }
        }
        
     
// TODO add your handling code here:
    }//GEN-LAST:event_jButton3MouseClicked
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {

        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {        
                 comboBoxWizard1.setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JRadioButton jRadioButton1;
    private javax.swing.JRadioButton jRadioButton2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    // End of variables declaration//GEN-END:variables
    
}
